home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre1.z / postgre1 / test / postfs.usr.bin / pwd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  625 b   |  36 lines

  1. #ifndef lint
  2. static    char sccsid[] = "@(#)pwd.c 1.1 90/03/23 SMI"; /* from UCB 4.4 83/01/05 */
  3. #endif
  4. /*
  5.  * pwd
  6.  */
  7. #include <stdio.h>
  8. #include <sys/param.h>
  9. #include "tmp/libpq-fs.h"
  10.  
  11. char *getwd();
  12. extern char *getenv();
  13.  
  14. main()
  15. {
  16.     char pathname[MAXPATHLEN + 1];
  17.     char *dbname;
  18.  
  19.     if ((dbname = getenv("DATABASE")) == (char *) NULL) {
  20.         fprintf(stderr, "no database specified in env var DATABASE\n");
  21.         fflush(stderr);
  22.         exit (1);
  23.     }
  24.  
  25.     PQsetdb(dbname);
  26.     
  27.     if (p_getwd(pathname) == NULL) {
  28.         fprintf(stderr, "ppwd: %s\n", pathname);
  29.         exit(1);
  30.     }
  31.     printf("%s\n", pathname);
  32.     PQfinish();
  33.     exit(0);
  34.     /* NOTREACHED */
  35. }
  36.